//
//  BiDismountParser.m
//  TrunkIndustryManageSystem
//
//  Created by WT_lyy on 15/4/30.
//  Copyright (c) 2015年 李璐西. All rights reserved.
//

#import "BiDismountParser.h"
#import "JSONKit.h"
#import "BiDismountEntity.h"
#import "BiFittingInfoEntity.h"
@implementation BiDismountParser

SINGLE_INSTANCE_IMPLEMENTION(BiDismountParser)

//获取改装列表
+ (NSDictionary *)parserCarDismountListEntity:(NSString*)jsonStr{
    
    NSDictionary * jsonDic = [jsonStr objectFromJSONStringWithParseOptions:JKParseOptionLooseUnicode];
    
    NSMutableArray * dataArr = [NSMutableArray array];
    
    id  data = jsonDic[@"data"];
    
    if ([data isKindOfClass:[NSArray class]]) {
        
        NSArray * Array = (NSArray *)data;
        
        for (int i = 0;i<Array.count;i++) {
            
            BiDismountEntity * dentity = [[BiDismountEntity alloc] init];
            
            NSDictionary * dataDic = Array[i][@"disassemblyInfo"];
            
            dentity.acceptanceDate = GET_NOT_NULL_STRING(dataDic[@"acceptanceDate"]);
            dentity.acceptancePersonId = GET_NOT_NULL_STRING(dataDic[@"acceptancePersonId"]);
            dentity.acceptancePersonName = GET_NOT_NULL_STRING(dataDic[@"acceptancePersonName"]);
            dentity.applyPerformance = GET_NOT_NULL_STRING(dataDic[@"applyPerformance"]);
            dentity.applyPersonId = GET_NOT_NULL_STRING(dataDic[@"applyPersonId"]);
            
            dentity.applyPersonName = GET_NOT_NULL_STRING(dataDic[@"applyPersonName"]);
            dentity.carId = GET_NOT_NULL_STRING(dataDic[@"carId"]);
            dentity.customerPhone = GET_NOT_NULL_STRING(dataDic[@"customerPhone"]);
            dentity.dismountAcceptanceRejectReason = GET_NOT_NULL_STRING(dataDic[@"dismountAcceptanceRejectReason"]);
            dentity.dismountApproveDate = GET_NOT_NULL_STRING(dataDic[@"dismountApproveDate"]);
            
            dentity.dismountApprovePersonId = GET_NOT_NULL_STRING(dataDic[@"dismountApprovePersonId"]);
            dentity.dismountApprovePersonName = GET_NOT_NULL_STRING(dataDic[@"dismountApprovePersonName"]);
            dentity.dismountPerformance = GET_NOT_NULL_STRING(dataDic[@"dismountPerformance"]);
            dentity.dismountPersonId = GET_NOT_NULL_STRING(dataDic[@"dismountPersonId"]);
            dentity.dismountPersonName = GET_NOT_NULL_STRING(dataDic[@"dismountPersonName"]);
            dentity.vin = GET_NOT_NULL_STRING(dataDic[@"vin"]);
            dentity.dismountRejectReason = GET_NOT_NULL_STRING(dataDic[@"dismountRejectReason"]);
            
            dentity.handlerId = GET_NOT_NULL_STRING(dataDic[@"handlerId"]);
            dentity.handlerName = GET_NOT_NULL_STRING(dataDic[@"handlerName"]);
            dentity.e_id = GET_NOT_NULL_STRING(dataDic[@"id"]);
            
            dentity.storeKeeperId = GET_NOT_NULL_STRING(dataDic[@"storeKeeperId"]);
            dentity.storeKeeperName = GET_NOT_NULL_STRING(dataDic[@"storeKeeperName"]);
            dentity.storePerformance = GET_NOT_NULL_STRING(dataDic[@"storePerformance"]);
            dentity.totalPerformance = GET_NOT_NULL_STRING(dataDic[@"totalPerformance"]);
            dentity.useCustomer = GET_NOT_NULL_STRING(dataDic[@"useCustomer"]);
            dentity.systemNumber = GET_NOT_NULL_STRING(dataDic[@"systemNumber"]);
            dentity.createTime = GET_NOT_NULL_STRING(dataDic[@"createTime"]);
            
            
            
            NSMutableArray * fetArr = [NSMutableArray array];
            if ([dataDic[@"fittingInfos"] isKindOfClass:[NSArray class]]) {
                
                NSArray * array = (NSArray *)dataDic[@"fittingInfos"];
                
                for (int i =0; i < array.count; i++) {
                    NSDictionary * fetDict = array[i];
                    BiFittingInfoEntity * fentity = [[BiFittingInfoEntity alloc] init];
                    
                    fentity.acceptanceDate = GET_NOT_NULL_STRING(fetDict[@"acceptanceDate"]);
                    fentity.dismountId = GET_NOT_NULL_STRING(fetDict[@"dismountId"]);
                    fentity.dismountReason = GET_NOT_NULL_STRING(fetDict[@"dismountReason"]);
                    fentity.expectedRecoverDate = GET_NOT_NULL_STRING(fetDict[@"expectedRecoverDate"]);
                    fentity.isAcceptance = GET_NOT_NULL_STRING(fetDict[@"isAcceptance"]);
                    
                    fentity.piecemealDate = GET_NOT_NULL_STRING(fetDict[@"piecemealDate"]);
                    fentity.productCount = GET_NOT_NULL_STRING(fetDict[@"productCount"]);
                    fentity.productDrawNumber = GET_NOT_NULL_STRING(fetDict[@"productDrawNumber"]);
                    fentity.productName = GET_NOT_NULL_STRING(fetDict[@"productName"]);
                    fentity.recoverDate = GET_NOT_NULL_STRING(fetDict[@"recoverDate"]);
                    
                    [fetArr addObject:fentity];
                }
                
            }
            dentity.fittingInfoArray = fetArr;
 
            [dataArr addObject:dentity];
            
        }
    }
    
    return [NSDictionary dictionaryWithObjectsAndKeys:jsonDic[@"response_status"],@"response_status",jsonDic[@"result_info"],@"result_info",dataArr,@"data", nil];
}

//获取改装审核驳回（完结）
+ (NSDictionary *)parserCarDismountCheckEntity:(NSString*)jsonStr{
    
    NSDictionary * jsonDic = [jsonStr objectFromJSONStringWithParseOptions:JKParseOptionLooseUnicode];
    
    return jsonDic;
}


@end
